package model

import (
	"goods-server/basic/config"
	"time"
)

type User struct {
	Id        uint64    `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	CreatedAt time.Time `gorm:"column:created_at;type:datetime(3);default:NULL;" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3);default:NULL;" json:"updated_at"`
	DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
	Account   string    `gorm:"column:account;type:char(30);comment:用户账号;default:NULL;" json:"account"`   // 用户账号
	Password  string    `gorm:"column:password;type:char(32);comment:用户密码;default:NULL;" json:"password"` // 用户密码
}

func (u *User) TableName() string {
	return "user"
}

// LoginUser登录
func (u *User) LoginUser() error {
	return config.DB.Where("account = ?", u.Account).First(u).Error
}
